import java.io.InputStream;

import org.kwis.msp.lcdui.Display;
import org.kwis.msp.lcdui.Jlet;

import org.kwis.msp.media.Clip;
import org.kwis.msp.media.Player;
import org.kwis.msp.handset.HandsetProperty;

import org.kwis.msp.lwc.Component;
import org.kwis.msp.lwc.LabelComponent;
import org.kwis.msp.lwc.ShellComponent;


public class ClipEx3 extends Jlet {   
	
	protected void startApp(String[] arg0) {
		try {

			int inStreamLength;
			byte[] buffer ;

			InputStream inStream = getClass().getResourceAsStream("/music.mid");
			
			inStreamLength=inStream.available();
			buffer = new byte[inStreamLength];
			inStream.read(buffer);

			Clip clip = new Clip("audio/MIDI", inStreamLength);

			clip.putData(buffer,0,inStreamLength);

			Player.play(clip, true);
			inStream.close();

		}catch(Exception e) {}


		ShellComponent shell = new ShellComponent();

		shell.setTitle("  Clip Play ");

		shell.show();

	}
	
	protected void destroyApp(boolean unconditional) {
	}

}